const Config = require("./config");
const webpack = require("webpack");
const path = require("path");

function resolve(dir) {
  return path.join(__dirname, ".", dir);
}

module.exports = {
  publicPath: "/",
  outputDir: "dist",
  assetsDir: "static",
  productionSourceMap: false,
  filenameHashing: true,
  lintOnSave: false,
  runtimeCompiler: true,
  devServer: {
    /* 自动打开浏览器 */
    open: true,
    /* 设置为0.0.0.0则所有的地址均能访问 */
    host: "0.0.0.0",
    port: 65535,
    https: false,
    /* 使用代理 */
    proxy: Config.proxyTable
  },
  configureWebpack: config => {
    // 占位符
    config.resolve.alias = Object.assign(config.resolve.alias, Config.alias);
    let _plugins = [];
    _plugins.push(
      new webpack.ProvidePlugin({
        REQUEST_API: "REQUEST_API",
        UTILS: "UTILS"
      })
    );
    config.plugins = [...config.plugins, ..._plugins];
  }
};
